In [1]:
import torch as th

In [2]:
import syft as sy

In [3]:
sy.create_sandbox(globals(), False, False)


Setting up Sandbox...
Done!

Step 1: Action Events


In [26]:
alices_params = th.tensor([1,2,3,4]).send(alice)
bobs_params = th.tensor([1,2,3,4]).send(bob)

In [27]:
input_data = th.tensor([1,2,3,4])

In [ ]:
# these ways of forming promises are identical
alice_data_promise = sy.promise(alice, id=input_data.id)
bob_data_promise = input_data.promise(bob)

In [ ]:
alices.promise_queue = {} 
# key = tensor ID
# value = list of function which required this tensor ID

# whenever alices.recv_obj is called, after it serializes the object, it checks the keys in the queue to see if there are any outstanding commands

In [ ]:
alices_result_promise = alices_params * alice_data_promise

In [ ]:


In [ ]:
bobs_result_promise = bobs_params * bobs_data_promise

In [ ]:
new_averaged_model = (alices_result_promise.get() + bobs_result_promise.get())/2

In [ ]:
# ASYNC using sockets

# input_data.send(bob)
# input_data.send(alice)

alice_data_promise.fulfill(input_data)
bobs_data_promise.fulfill(input_data)

In [ ]:
print(new_averaged_model.get())

In [ ]:

Scratch


In [5]:
class Promise():
    
    def __init__(self, id):
        
        self.operations = list()
        self.trigger_id = id
        
    def fulfill(self, tensor):
        ""
        
    
    def __add__(self, other_promise):
        return

In [11]:
x = Promise(10)

In [12]:
y = x + x

In [14]:
y

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: